package cn.zn.modules.pz.enums;

import cn.hutool.core.collection.CollUtil;
import cn.zn.framework.common.vo.ComboxItemVO;
import lombok.Getter;

import java.util.List;

@Getter
public enum ProcessLevelEnum {
	/**
	 * 正常
	 */
	state_1(1, "正常"),
	state_2(2, "重要"),
	state_3(3, "紧急"),;

	private Integer code;
	private String name;

	ProcessLevelEnum(Integer code, String name) {
		this.code = code;
		this.name = name;
	}

	public static ProcessLevelEnum findByCode(int code) {
		for (ProcessLevelEnum e : values()) {
			if (e.getCode() == code) {
				return e;
			}
		}
		return null;
	}

	public static List<ComboxItemVO> buildCombox() {
		List<ComboxItemVO> list = CollUtil.newArrayList();
		ProcessLevelEnum processLevelEnum;
		for (int i = 0; i < values().length; i++) {
			processLevelEnum = values()[i];
			list.add(ComboxItemVO.builder()
					.value(processLevelEnum.code)
					.text(processLevelEnum.name)
					.build());
		}
		return list;
	}
}
